package org.example.chainOfRespon.chainOfResponPl;

import org.omg.CORBA.IDLTypeHelper;

public abstract class Handler {

    private Handler nextHandler;

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public abstract Level getLevel();

    public abstract Response echo(Request request);

    public final Response handlerMessage(Request request){
        Response response=null;
        if (this.getLevel().equals(request.getRequestLevel())){
            response=this.echo(request);
        }else if (this.nextHandler != null){
            response=this.nextHandler.handlerMessage(request);
        }

        return response;
    }
}
